package org.eclipse.emf.cdo.ui.merge;


import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;

/**
 * The object for a leaf of a tree for a change operation.
 *
 * @author Thomas Halmetschlager
 */
public class MergeTreeObject extends TreeObject{
	
	/** The revision key. */
	private CDORevisionKey revision;
	
	/** The CDO ID. */
	private CDOID cdoid;
	
	/** The branch point. */
	private CDOBranchPoint branch;
	
	/** The feature delta. */
	private CDOFeatureDelta feature;
	
	/**
	 * Gets the feature delta.
	 *
	 * @return the feature delta
	 */
	public CDOFeatureDelta getFeature() {
		return feature;
	}

	/**
	 * Sets the feature delta.
	 *
	 * @param feature the new feature delta
	 */
	public void setFeature(CDOFeatureDelta feature) {
		this.feature = feature;
	}

	/**
	 * Instantiates a new merge tree object.
	 *
	 * @param name the name
	 */
	public MergeTreeObject(String name){
		super(name);
	}
	
	/**
	 * Gets the pranch point.
	 *
	 * @return the pranch point
	 */
	public CDOBranchPoint getBranch() {
		return branch;
	}

	/**
	 * Sets the pranch point.
	 *
	 * @param branch the new pranch point
	 */
	public void setBranch(CDOBranchPoint branch) {
		this.branch = branch;
	}

	/**
	 * Instantiates a new merge tree object.
	 *
	 * @param revision the revision key
	 */
	public MergeTreeObject( CDORevisionKey revision) {
		super(revision.toString());
		this.revision = revision;
		this.cdoid = revision.getID();
	}
	
	/**
	 * Instantiates a new merge tree object.
	 *
	 * @param revision the revision key
	 * @param name the name
	 */
	public MergeTreeObject( CDORevisionKey revision, String name) {
		super(name);
		this.revision = revision;
		this.cdoid = revision.getID();
	}

	/**
	 * Instantiates a new merge tree object.
	 *
	 * @param id the id
	 */
	public MergeTreeObject( CDOID id) {
		super("Delete: " + id.toString());
		this.revision = null;
		this.cdoid = id;
	}
	
	/**
	 * Gets the revision key.
	 *
	 * @return the revision key
	 */
	public CDORevisionKey getRevision() {
		return revision;
	}

	/**
	 * Sets the revision key.
	 *
	 * @param revision the new revision key
	 */
	public void setRevision(CDORevisionKey revision) {
		this.revision = revision;
	}

	/**
	 * Gets the CDO ID.
	 *
	 * @return the CDO ID
	 */
	public CDOID getCdoid() {
		return cdoid;
	}

	/**
	 * Sets the CDO ID.
	 *
	 * @param cdoid the new CDO ID
	 */
	public void setCdoid(CDOID cdoid) {
		this.cdoid = cdoid;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.emf.cdo.ui.merge.TreeObject#toString()
	 */
	@Override
	public String toString(){
		return getName();
		
	}
}
